package com.keya.features.operations;

import com.keya.base.sh.RunShell;
import com.keya.base.sh.RunShellRet;
import io.micrometer.core.instrument.Metrics;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class EchoScuOp {
    private String host;

    private String port;

    // self
    private String aet;

    // peer
    private String aec;

    private Integer timeout;

    public RunShellRet run() throws Exception {
        return Metrics.timer("op_echoscu").recordCallable(this::runShellRet);
    }

    public RunShellRet runShellRet() throws Exception {
        String[] cmds = {"echoscu", host, port, "--call", aec, "--aetitle",
                aet, "-to", Integer.toString(timeout)};
        return RunShell.runShell("echoscu", cmds, (timeout + 1) * 1000);
    }
}
